#!/usr/bin/env python
# coding: utf-8
# @Time    : 2021/11/22 16:10
# @Author  : YD
# @Email   : dinhe_1985@126.com 
# @File    : zbx_log.py.py
# @Software: PyCharm
# @Blog    : www.noteshare.cn
import logging.config
from conf.logging_conf import *
from conf.api_conf import *


class LoggingRecord:
    def __init__(self, logger, log_level):
        self.logger = logger
        self.log_level = log_level

    def set_logging(self):
        with open(LOGFILE_PATH, 'a+'):
            logging.config.dictConfig(LOGGING_CONFIG)
            logger = logging.getLogger(self.logger)
        return logger

    def info(self, msg):
        logger = self.set_logging()
        try:
            logger.info(msg)
        except:
            print('log info {}'.format(msg))

    def warning(self, msg):
        logger = self.set_logging()
        try:
            logger.info(msg)
        except:
            print('log info {}'.format(msg))

    def critical(self, msg):
        logger = self.set_logging()
        try:
            logger.info(msg)
        except:
            print('log info {}'.format(msg))

    def error(self, msg):
        logger = self.set_logging()
        try:
            logger.error(msg)
        except:
            print('log info {}'.format(msg))
